﻿<?xml version="1.0" encoding="utf-8"?>

<xs:schema id="ProcessDefinition" xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:simpleType name="TermExpirationAction">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Autocomplete" />
			<xs:enumeration value="Wait" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="TaskType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="None" />
			<xs:enumeration value="Read" />
			<xs:enumeration value="Approve" />
			<xs:enumeration value="Sign" />
			<xs:enumeration value="Execute" />
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name="ActionRule">
		<xs:attribute name="Condition" type="xs:string" use="required" />
		<xs:attribute name="Action" type="xs:string" use="required" />
	</xs:complexType>

	<xs:complexType name="Assignment">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="ActionRule" type="ActionRule" minOccurs="0" />
		</xs:choice>

		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Title" type="xs:string" use="required" />

		<xs:attribute name="TaskType" type="TaskType" use="optional" default="None" />
		<xs:attribute name="TaskTitle" type="xs:string" use="required" />
		<xs:attribute name="TaskDescription" type="xs:string" use="optional" />
		<xs:attribute name="TaskContentTypeId" type="xs:string" use="optional" />

		<xs:attribute name="PrincipalName" type="xs:string" use="required" />

		<xs:attribute name="AllowDelegation" type="xs:boolean" use="optional" default="true" />
		<xs:attribute name="AllowSuspending" type="xs:boolean" use="optional" default="true" />

		<xs:attribute name="Term" type="xs:duration" use="optional" default="P0D" />
		<xs:attribute name="TermExpirationAction" type="TermExpirationAction" use="optional" default="Wait" />
		<xs:attribute name="TermExpirationOutcome" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="Custom">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="ActionRule" type="ActionRule" minOccurs="0" />
		</xs:choice>

		<xs:attribute name="Name" type="xs:string" use="required" />
	</xs:complexType>

	<xs:complexType name="Pause">
		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Duration" type="xs:duration" use="required" />
	</xs:complexType>

	<xs:simpleType name="ProcessMode">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Parallel" />
			<xs:enumeration value="Sequential" />
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name="Process">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="Assignment" type="Assignment" minOccurs="0" />
			<xs:element name="Custom" type="Custom" minOccurs="0" />
			<xs:element name="Pause" type="Pause" minOccurs="0" />
			<xs:element name="Process" type="Process" minOccurs="0" />
		</xs:choice>

		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Mode" type="ProcessMode" use="required" />
	</xs:complexType>

	<xs:element name="Process" type="Process" />
</xs:schema>